package com.abase.site.server.servirces;

import com.abase.site.client.services.PocAbaseService;
import com.abase.site.shared.AbaseException;
import com.abase.site.shared.AbaseProfile;
import com.abase.site.shared.AbaseException.AbaseExcpetionCodes;
import com.abase.site.shared.login.LoginRequest;
import com.abase.site.shared.login.LoginResponse;

public class AuthentificationServiceMock implements PocAbaseService {

	@Override
	public LoginResponse doLogin(LoginRequest request)
			throws AbaseException {
		if (request.getLogin().equals("abase") && request.getPassword().equals("abase")) {
			final LoginResponse response = new LoginResponse();
			
			final AbaseProfile profil = new AbaseProfile();
			profil.setEmail("poc.abase@abase.fr");
			profil.setNom("abase");
			profil.setPrenom("poc");
			
			response.setAbaseProfile(profil);
			return response;
		} else if (request.getLogin().equals("abase") && !request.getPassword().equals("abase")) {
			throw new AbaseException(AbaseExcpetionCodes.ABASE_AUTH_BAD_PASSWORD);
		} else {
			throw new AbaseException(AbaseExcpetionCodes.ABASE_AUTH_BAD_LOGIN);
		}
		
	}

}
